package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import com.atguigu.springcloud.service.PaymentFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: cloud2020
 * @description: TODO
 * @author: YuWenYi
 * @create: 2021-04-14 21:14
 **/
@RestController
public class OrderFeignController {

    @Autowired
    PaymentFeignService paymentFeignService;

    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
        //使用openFeign进行RMI
        return paymentFeignService.getPaymentById(id);
    }

    //使用openFeign服务,一般客户端等待时间不超过1秒,否则就会报超时错误,可以在yml中设置其时长
    @GetMapping(value = "/consumer/payment/feign/timeout")
    String paymentFeignTimeout(){
        return paymentFeignService.paymentFeignTimeout();
    }

}
